package com.aaa.home.controller;

import com.aaa.common.vo.Result;
import com.aaa.home.service.TbLinkService;
import com.aaa.home.vo.AddLinkVo;
import com.aaa.home.vo.LinkVo;
import com.aaa.home.vo.Zone.HeadNavAddVo;
import com.aaa.home.vo.ZoneVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：Mickey
 * @date ：Created in 2022/12/8 0:48
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/home/link")
@Api(tags = "友情链接接口类")
public class TbLinkController {

    @Autowired
    private TbLinkService linkService;

    //查询所有链接并且分页加条件查询
    @PostMapping("/getAllLink/{current}/{pageSize}")
    public Result findLinkByPage(@RequestBody LinkVo linkVo,
                                 @PathVariable Integer current,
                                 @PathVariable Integer pageSize
    ){
        return linkService.getAllLinkPage(linkVo,current,pageSize);
    }

    //改变友情链接状态
    @PostMapping("/changeStatus/{linkId}/{isDisable}")
    public Result updateLinktatus(@PathVariable String linkId,
                                   @PathVariable Integer isDisable){
        return linkService.updateZoneStatus(linkId,isDisable);
    }

    //添加友情链接
    @PostMapping("/addLink")
    public Result addLink(@RequestBody AddLinkVo addLinkVo){
        return linkService.addLink(addLinkVo);
    }

    //删除友情链接
    @PostMapping("/deleteLink/{linkId}")
    public Result deleteLinkById(@PathVariable String linkId){
        System.out.println("删除头部导航"+linkId);
        return linkService.deleteLinkById(linkId);
    }
}
